﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:local="clr-namespace:ReportingManagement.Components.Queries" 
    x:Class="ReportingManagement.Components.Queries.ReportParameterCollector" 
    mc:Ignorable="d" Width="540" Title="Report Parameter Collectors" SizeToContent="Height" ResizeMode="NoResize"
    d:DesignHeight="402" d:DesignWidth="485" ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Margin="10" x:Name="gridParameterCollector">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <local:ReportParameterRetriever ParameterValue="Erroneous Value" ValidatingRegularExpression="\d{5}" ParameterName="Start Period" IsValid="{Binding IsValid}"
                                            ParameterDescription="This is the number between 1 and 12 that represents one of the month in the year. e.g. 3 for March" />
            <local:ReportParameterRetriever ValidatingRegularExpression="^\d{5}$" Grid.Row="1" ParameterName="{Binding Name}" x:Name="demo"
                                            ParameterDescription="{Binding Description}" IsValid="{Binding IsValid}" ParameterValue="{Binding Value}" />                    
        </Grid>

        <ListBox x:Name="lstParameters" Grid.Row="1" Margin="10" HorizontalContentAlignment="Stretch" 
                 VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
            <ListBox.Resources>
                <Style TargetType="{x:Type ListBox}">
                    <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue" />
                </Style>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="IsTabStop" Value="False" />
                </Style>
            </ListBox.Resources>
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Focusable" Value="False" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <local:ReportParameterRetriever ValidatingRegularExpression="{Binding ValidationExpression}" 
                                                        ParameterName="{Binding Name}" ParameterValue="{Binding Value}"
                                                        ParameterDescription="{Binding Description}" IsValid="{Binding IsValid}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Border Grid.Row="2" BorderBrush="#FFD0D0D4" BorderThickness="2" Margin="10">
            <DockPanel LastChildFill="False" Background="#FFE6E6EA">
                <Button x:Name="btnCancel" Content="Cancel" DockPanel.Dock="Right" Margin="5" Padding="15,3" IsCancel="True" />
                <Button x:Name="btnOK" Content="OK" DockPanel.Dock="Right" Margin="5" Padding="20,3" IsDefault="True" Click="btnOK_Click" />
            </DockPanel>
        </Border>
    </Grid>
    
</Window>
